subroutine simYP_f(rand_u,w1,grid,n,smav,simPY1,simPY2)
INTEGER, INTENT(IN) :: n
REAL, INTENT(IN) :: rand_u, smav
REAL, INTENT(IN) :: w1(n,1), grid(n,1)
real, INTENT(OUT) :: simPY1, simPY2
  
if (rand_u<w1(1,1)) then
   simPY1 = grid(1,1)*smav
   simPY2 = grid(3,1)*smav !reverse shock to generate mean zero across sims (apart from unemp.)
else
   if (rand_u<w1(2,1)+w1(1,1)) then
      simPY1 = grid(2,1)*smav
      simPY2 = grid(2,1)*smav      
   else
         simPY1 = grid(3,1)*smav
         simPY2 = grid(1,1)*smav !reverse shock to generate mean zero across sims (apart from unemp.)
  end if    
end if

end subroutine
